package com.xdja.myapplication

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.recyclerview.widget.LinearLayoutManager
import com.xdja.myapplication.adapter.RecyclerViewAdapter
import com.xdja.myapplication.demo.FoldingToolbarActivity
import com.xdja.myapplication.demo.SlideFollowActivity
import com.xdja.myapplication.demo.SlideFollowFixActivity
import com.xdja.myapplication.demo.SunMoonActivity
import com.xdja.myapplication.demo.viewpager.ViewPagerActivity
import kotlinx.android.synthetic.main.activity_motionlayout_slide_follow.*

class MotionLayoutActivity : AppCompatActivity(), RecyclerViewAdapter.OnItemClickListener {

    private var data = arrayListOf<String>()
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_recyclerview)


        data.add("OnSwipe")
        data.add("OnClick")
        data.add("Attributes")
        data.add("Custom_attributes")
        data.add("Motion Transform")
        data.add("KeyPosition")
        data.add("KeyAttribute")
        data.add("KeyCycle")
        data.add("[Demo]SlideFollow")
        data.add("[Demo]SlideFollowFix")
        data.add("[Demo]FoldingToolbar")
        data.add("[Demo]LocationAndBackground")
        data.add("[Demo]ViewPager")


        list?.layoutManager = LinearLayoutManager(this)
        val recyclerViewAdapter = RecyclerViewAdapter(data)
        list?.adapter = recyclerViewAdapter
        recyclerViewAdapter.setOnItemClickListener(this)
    }

    override fun onItemClick(position: Int) {
        var myIntent: Intent
        when (position) {
            0 -> {

                myIntent = Intent(this, MotionDemoActivity::class.java)
                myIntent.putExtra("layout_file_id", R.layout.activity_motionlayout_basic_demo)
            }
            1 -> {
                myIntent = Intent(this, MotionDemoActivity::class.java)
                myIntent.putExtra("layout_file_id", R.layout.activity_motionlayout_basic_demo_click)
            }
            2 -> {
                myIntent = Intent(this, MotionDemoActivity::class.java)
                myIntent.putExtra(
                    "layout_file_id",
                    R.layout.activity_motionlayout_basic_demo_attrubutes
                )
            }
            3 -> {
                myIntent = Intent(this, MotionDemoActivity::class.java)
                myIntent.putExtra(
                    "layout_file_id",
                    R.layout.activity_motionlayout_basic_demo_custom_attrubutes
                )
            }
            4 -> {
                myIntent = Intent(this, MotionDemoActivity::class.java)
                myIntent.putExtra(
                    "layout_file_id",
                    R.layout.activity_motionlayout_basic_demo_motion
                )
            }
            5 -> {
                myIntent = Intent(this, MotionDemoActivity::class.java)
                myIntent.putExtra(
                    "layout_file_id",
                    R.layout.activity_motionlayout_basic_keyposition
                )
            }
            6 -> {
                myIntent = Intent(this, MotionDemoActivity::class.java)
                myIntent.putExtra(
                    "layout_file_id",
                    R.layout.activity_motionlayout_basic_keyattrubutes
                )
            }
            7 -> {
                myIntent = Intent(this, MotionDemoActivity::class.java)
                myIntent.putExtra(
                    "layout_file_id",
                    R.layout.activity_motionlayout_basic_keycycle
                )
            }

            8 -> {
                myIntent = Intent(this, SlideFollowActivity::class.java)
            }
            9 -> {
                myIntent = Intent(this, SlideFollowFixActivity::class.java)
            }
            10 -> {
                myIntent = Intent(this, FoldingToolbarActivity::class.java)
            }


            11 -> {

                myIntent = Intent(this, SunMoonActivity::class.java)
            }
            12 -> {
                myIntent = Intent(this, ViewPagerActivity::class.java)
            }
            else -> {
                myIntent = Intent(this, MotionDemoActivity::class.java)
                myIntent.putExtra("layout_file_id", R.layout.activity_motionlayout_basic_demo)
            }
        }
        startActivity(myIntent)
    }

}
